# https://www.cnblogs.com/alex-13/p/12016554.html
# https://zhuanlan.zhihu.com/p/127837363
from selenium import webdriver
import time

# 声明浏览器
browser = webdriver.Chrome()

# 找到html文件并打开
Path_name = 'D:/gitworkspace/python100/Day49/selenium.html'
browser.get(Path_name)

# 查找元素并操作
User_name = browser.find_element_by_css_selector('[name="username"]').send_keys('rabbit')
time.sleep(2)
Pass_word = browser.find_element_by_css_selector('[name="password"]').send_keys('love')
time.sleep(2)
Confirm_button = browser.find_element_by_css_selector('#sub').click()
time.sleep(3)

# 获取标题和URL
print('当前页面的URL为：', browser.current_url)
print('当前页面的标题为：', browser.title)
time.sleep(3)

# 关闭浏览器
browser.quit()

